{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ad7f42c9",
   "metadata": {},
   "source": [
    "-----------------\n",
    "* 2022-8-30\n",
    "* python学习第二周\n",
    "* 记录人：wxm\n",
    "----------------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1898d6b",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "## 1.Head First Python P4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "86496146",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "276164"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.datetime.today().microsecond"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "7254e1fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "37\n",
      "现在是秒/时间为奇数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "# print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().second\n",
    "\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为奇数\")\n",
    "else:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为偶数\")\n",
    "\n",
    "# print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "02f0dd1d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 判断当前是一周中的星期几，如果是星期二，然后打印Python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "966f4506",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "4816f2aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "777ff5a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天有Python课，时间为：下午2：30-4：50\n"
     ]
    }
   ],
   "source": [
    "# tm_wday:  0-6  0 是星期一\n",
    "今天 = time.localtime().tm_wday\n",
    "\n",
    "if 今天 == 1:\n",
    "    print(\"今天有Python课，时间为：下午2：30-4：50\")\n",
    "else:\n",
    "    print(\"今天没有Python课\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "2666dd25",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "7335aecf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "16"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_hour  # 是不是在14到16之间  如果是14 再看tm_minute 是不是在0-30  如果是16的话， 再看tm_minute是不是在50以上"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0d8f2b2",
   "metadata": {},
   "source": [
    "# 课后练习\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "11538b3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing么？然后打印Python课表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6683d607",
   "metadata": {},
   "source": [
    "# 2.1 模块--标准库\n",
    "* 标准库是python开发团队为Python用户日常需求而写好的一些模块，可以直接使用：import模块名称\n",
    "\n",
    "> 1. sys模块\n",
    "> 2. os模块\n",
    "> 3. datetime模块\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dff7e5bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2.2模块--开源模块(pypi.org)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94bf18ca",
   "metadata": {},
   "source": [
    "# 2.3自定义模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2c688df",
   "metadata": {},
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c1e9d1c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7d12e351",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "53ba4e56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\2022-2023 wang'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "2393eec0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "6c8024ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 8, 30)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2cb84835",
   "metadata": {},
   "source": [
    "# 认识下 time 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6cfe34ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "6117effc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=14, tm_min=29, tm_sec=42, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "49f92b7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1661841034.803036"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time() # 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "09d87ac7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "52.69677410420436"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()/60/60/24/365"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "6cac7086",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1970"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2022-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "fb92b046",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=30, tm_hour=7, tm_min=44, tm_sec=50, tm_wday=1, tm_yday=242, tm_isdst=0)"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "720ba350",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'apple'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_13796/2364371656.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mapple\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'apple'"
     ]
    }
   ],
   "source": [
    "import apple"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1d8a246b",
   "metadata": {},
   "source": [
    "# 3.赋值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a62a22c2",
   "metadata": {},
   "source": [
    "# 4. 变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "8c6bd62e",
   "metadata": {},
   "outputs": [],
   "source": [
    "walt_time = 26 \n",
    "walt_time = 34\n",
    "\n",
    "gf_of_11u = \"Lucy\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "d220e296",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "walt_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "2342595f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "walt_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e71e6289",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
